<?php
/**
 * @name /www/unit-tests/User.php
 * @author
 * @version 2011.04.2
 *
 * handling changes to user information
 */

// Sets up configuration settings and includes libraries.
require_once('_ini.php');
// Libraries
ReqLib('/lib/private/NeededItem.php');

$NeededItemId = $_POST['NeededItemId'];
$ItemName = $_POST['ItemName'];
$OrphanageName = $_POST['OrphanageName'];
$NeededQuantity = $_POST['NeededQuantity'];
$QuantitySent = $_POST['QuantitySent'];
$DateRequested = $_POST['DateRequested'];
$NeededNotes = $_POST['NeededNotes'];

//print($DateRequested);
//die();

$Action = $_POST['Action'];

if($Action=="Update Needed Item Info")
{
	$ni = new NeededItem();

	$ni->Load($NeededItemId);

	$ni->ItemId = Item::GetItemIdByItemName($ItemName);
	$ni->OrphanageId = Orphanage::GetOrphanageIdByOrphanageName($OrphanageName);
	$ni->NeededQuantity = $NeededQuantity;
	$ni->QuantitySent = $QuantitySent;
	$ni->DateRequested = $DateRequested;
	$ni->NeededNotes = $NeededNotes;
	$ni->Save();

?>
	<script language="javascript">
		if(window.confirm("Needed Item information has been added successfully.\nDo you want to update more information?"))
			document.location.replace("neededItems.php");
		else
			document.location.replace("account.php");
	</script>
<?
}

else if($Action=="Delete Needed Item")
{
	$ni = new NeededItem();

	$ni->Delete($NeededItemId);
?>
	<script language="javascript">
		if(window.confirm("This Needed Item has been deleted successfully.\nDo you want to delete more Needed Item?"))
			document.location.replace("neededItems.php");
		else
			document.location.replace("account.php");
	</script>
<?
}
	//php code for other actions will go here
?>

